﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SinaAPIDocumentToRequestTool
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            dataGetter = new V2DocumentDataGetter();
            dataGetter.Init(webBrowser1);
            folderBrowserDialog1.Description = "请选择输出根目录";

            var ps=Application.StartupPath.Split('\\');
            ps=ps.Take(ps.Length -3).ToArray();

            folderBrowserDialog1.SelectedPath = string.Join("\\", ps) +@"\SinaJDCBClient\SinaWeiboClientV2\ContractSource\";
            var fl = this.folderBrowserDialog1.ShowDialog();

            if (fl != System.Windows.Forms.DialogResult.OK)
            {
                Path = ".";
            }
            else
            {
                Path = this.folderBrowserDialog1.SelectedPath;
            }

        }

        string Path;


        private DocumentDataGetterBase dataGetter;
        private void toolStripButton3_Click(object sender, EventArgs e)
        {

            var f = new XmlViewer(dataGetter) { PathRoot = Path };
            f.Show(this);
            //MessageBox.Show(dataGetter.GetPath());
            //MessageBox.Show(dataGetter.GetComment());
            //MessageBox.Show(dataGetter.GetParamsAndParamsComment().Count.ToString());
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            dataGetter.GoHome();
        }

        private void toolStripContainer1_TopToolStripPanel_Click(object sender, EventArgs e)
        {

        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.webBrowser1.GoBack();
        }
    }
}
